CLASS zcl_ymoon_mail_custom DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    INTERFACES if_rap_query_provider .
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS ZCL_YMOON_MAIL_CUSTOM IMPLEMENTATION.


  METHOD if_rap_query_provider~select.
    DATA:lt_tab TYPE TABLE OF ymoon_i_email.
    DATA(paging) = io_request->get_paging(  ).

    DATA(config_instance) = cl_bcs_mail_system_config=>create_instance( ).


    DATA(allowed_recipient_domains) = config_instance->read_allowed_recipient_domains( ).

    SELECT * FROM ymoon_i_email INTO TABLE @DATA(lt_select).

    lt_tab = VALUE #( FOR domain IN allowed_recipient_domains ( email = domain ) ).


    LOOP AT lt_tab ASSIGNING FIELD-SYMBOL(<fs_line>).
      TRY.
          DATA(ls_select) = lt_select[ email = <fs_line>-email ].
          "…后续处理
          IF sy-subrc = 0.
            <fs_line>-name = ls_select-name.
          ENDIF.
        CATCH cx_sy_itab_line_not_found.
          "…未找到的处理
      ENDTRY.


    ENDLOOP.

    IF io_request->is_data_requested( ).
      io_response->set_data( lt_tab ).
    ENDIF.

    IF io_request->is_total_numb_of_rec_requested( ).
      io_response->set_total_number_of_records( 2 ).
    ENDIF.





  ENDMETHOD.
ENDCLASS.
